package com.ymatou.app.api.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * 根据ID获取单个收货地址Call FreeMaker Template自动生成代码
 */
public class GetAddressByIdCall extends YmatouBaseCall {
	private static String opurl = "api/Address/GetAddressById";

	public GetAddressByIdCall() {
		super(EnvSetup.getSystemUrl("api_app"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("Code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getBCode() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("BCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("Msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public JSONObject getData() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("Data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}

	/**
	 * 获取AddressList
	 * 
	 * @return
	 */
	public JSONObject getAddress() {
		JSONObject Address = null;
		try {
			Address = getData().getJSONObject("Address");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return Address;
	}

	/**
	 * 获取AddressId
	 * 
	 * @return
	 * @return
	 */
	public int getAddressId() {
		int AddressId = 0;
		try {
			AddressId = getAddress().getInt("AddressId");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return AddressId;
	}

	/**
	 * 获取UserId
	 * 
	 * @return
	 * @return
	 */
	public int getUserId() {
		int UserId = 0;
		try {
			UserId = getAddress().getInt("UserId");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return UserId;
	}
}